package ca.usask.cs.drawTree;

import processing.core.PApplet;
import processing.core.PFont;

import com.nootropic.processing.layers.Layer;

public class TimeRuler  extends Layer  {
	
	int transparancy = 200;
	static final int rulerColor = 0xff000000;
	int RulerWidth ;
	public static int RulerHeight;
	DrawControler controler = new DrawControler();
	float lineX1=0,lineY1,lineY2;
	HorizontalScrollbar hBar;
	static float[] XList;
	
	TimeRuler(int rw,int rh,PApplet parent, HorizontalScrollbar ihBar) {

		super(parent); // This is necessary!
		RulerWidth = rw;
		RulerHeight = rh;
		controler = (DrawControler) parent;
		hBar = ihBar;
	//	XList = new ;
	}

	public void draw() {
		background(0, 0); // clear the background every time, but be transparent
		smooth();
		stroke(126);
		strokeWeight(0);
		fill(rulerColor,transparancy);
		rect(0, RulerHeight-20, RulerWidth, 20);
	//	float offset = (hBar.newspos - hBar.spos) /hBar.loose;
		drawRulerLines();
		
		

}
	void drawRulerLines(){
		int lineType = 0;
		float lineX = 0;
		lineX1 = 0;
		lineY1 = TimeRuler.RulerHeight-20;
		lineY2 = TimeRuler.RulerHeight;
		if(controler.roottheNode.Ndtype%2==0){
			lineX1 += controler.dBranchTime;
			lineType = 0;
		}
		else{
			lineX1 += controler.cBranchTime;
			lineType = 1;
		}
		
		lineX1 +=(hBar.newspos-(0 + (controler.width - 10)/2 - 7.5))/5;
		for(int i=0;i<controler.layer;i++){
			strokeWeight(3); 
			strokeCap(controler.ROUND);
			
			
		//	lineX1 +=controler.sval;
			System.out.println(lineX1+"");
			line(lineX1,lineY1,lineX1,lineY2);
//			lineX1 = lineX1 + distanceForEachLayer;
			lineType++;
			if(lineType%2==0){
				lineX = controler.dBranchTime;
			}
			else{
				lineX = controler.cBranchTime;
			}
			lineX1 += lineX;
			
		}
	}
}